home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9103 / lastlog / findids.c < prev    next >
C/C++ Source or Header  |  1991-02-17  |  4KB  |  100 lines

  1. /*****************************************************************
  2. *  FindIDs.C
  3. *  written by Kathy Cea, Platinum Software Int'l
  4. *
  5. *  Finds and lists all users who have an application-specific
  6. *  id (any property ending in "ID") stored in the bindery
  7. *
  8. *  Calling Syntax:
  9. *       FindIDs
  10. *
  11. *   Compiled in Turbo C 2.0 with NetWare C function calls
  12. *****************************************************************/
  13.  
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <nit.h>
  17. #include <niterror.h>
  18.  
  19. long objectId;
  20. BYTE propertyValue[128];
  21. BYTE moreSegs = 255,
  22.      propertyFlags;
  23. int segNum = 1;
  24. BYTE temp[3];
  25. BYTE holdobjId[9];
  26. char *endptr;
  27. WORD objectType;
  28. char objectName[48];
  29. char propertyName[16];
  30. char applName[14];
  31. long seqNumber;
  32. BYTE propertyFlags,
  33.      propertySecurity,
  34.      propertyHasValue,
  35.      moreProperties;
  36. int retcode;
  37. int i,j;
  38. int foundone = 0;
  39.  
  40. main()
  41. {
  42.     printf("\tUser\t\t\tApplication\n");
  43.     printf("\t-----------------------------------------\n");
  44.  
  45. /* Get all users of group EVERYONE
  46.    Object ID of users are passed back in the propertyValue field
  47.    Up to 32 Object Ids can be returned on each pass.  Continue
  48.    calling ReadPropertyValue until moreSegs is No (0) */
  49.  
  50.     while (moreSegs) {
  51.         retcode = ReadPropertyValue("EVERYONE", OT_USER_GROUP,
  52.                             "GROUP_MEMBERS", segNum,
  53.                             propertyValue, &moreSegs, &propertyFlags);
  54.         segNum++; /* increment the segment number to read next */
  55.  
  56.     /* parse the propertyValue for 4-byte Object IDs,
  57.        then convert each ID to a long integer */
  58.         i = 0;
  59.         temp[2] = '\0';
  60.         holdobjId[0] = '\0';
  61.         while (i < 128) {
  62.             for (j=0; j < 4; j++) {
  63.                 /* Build a hex string for each Object ID */
  64.                 sprintf(temp, "%02x", propertyValue[i]);
  65.                 temp[2] = '\0';
  66.                 strcat(holdobjId, temp);
  67.                 i++;
  68.             } /* for (j=0; j < 4; j++) */
  69.  
  70.             objectId = strtoul(holdobjId, &endptr, 16);
  71.  
  72.             /* Pass user's Object ID and receive User Name */
  73.             retcode = GetBinderyObjectName(objectId, objectName, &objectType);
  74.             if (retcode == SUCCESSFUL)  {
  75.             /* Start scanning for application-id properties
  76.                (anything ending in "ID") */
  77.                 moreProperties = 255;
  78.                 seqNumber = -1;
  79.                 while ((moreProperties) && (retcode == SUCCESSFUL)){
  80.                     retcode = ScanProperty(objectName,OT_USER,"*ID",&seqNumber,
  81.                                propertyName,&propertyFlags,&propertySecurity,
  82.                                &propertyHasValue,&moreProperties);
  83.                 /* if the property is found, list user's name and appl name */
  84.                     if (retcode == SUCCESSFUL) {
  85.                         /* strip the "ID" from the application name before printing */
  86.                         strncpy(applName,propertyName,strlen(propertyName) - 2);
  87.                         applName[strlen(propertyName) - 2] = '\0';
  88.                         printf("\t%-20s\t%-16s\n",objectName,applName);
  89.                         foundone = 1;
  90.                     }
  91.                 }/* while ((moreProperties)&& */
  92.             } /* if (retcode == SUCCESSFUL) */
  93.             holdobjId[0] = '\0';
  94.         }  /* while (i < 128) */
  95.     } /* while (moreSegs) */
  96.     if (!foundone)
  97.         printf("\t** No application IDs found in the bindery **\n");
  98. } /* main() */
  99.  
  100.